package org.zfm.car.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.zfm.car.domain.CarResources;
import org.zfm.car.mapper.CarResourcesMapper;
import org.zfm.car.service.ICarResourcesService;
import org.zfm.base.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * @author zara
 * @since 2022-11-03
 */
@Service
public class CarResourcesServiceImpl extends BaseServiceImpl<CarResources> implements ICarResourcesService {

    @Autowired
    private CarResourcesMapper carResourcesMapper;
    @Override
    @Transactional
    public void deleteByCarId(Long carId) {
        carResourcesMapper.deleteByCarId(carId);
    }

    @Override
    @Transactional
    public void add(CarResources carResources) {
        //先删除
        carResourcesMapper.deleteByCarId(carResources.getCarId());
        //再新增
        carResourcesMapper.insert(carResources);
    }
}
